import Table from './table'
import Chart from './chart'
import Graph from './graph'
import ReadMore from './read-more'
import Progress from './progress'
import Scroller from './scroller'
import SearchForm from './search-form'
import Descriptions from './descriptions/index.vue'
import Desc from './desc/index.vue'
import DescItem from './desc/item.vue'
import Searcher from './searcher/index.vue'
import RadioGroup from './radio-group/index.vue'
import CheckboxGroup from './checkbox-group/index.vue'
import Selector from './selector/index.vue'
import Buttons from './button'
import Menu from './menu'

// 拼接组件名称
function extractComps(comps) {
  const newCompsMap = {}
  Object.keys(comps).forEach((compName) => {
    const compsMap = comps[compName]
    Object.keys(compsMap).forEach((key) => {
      // 如果key为Index，则不拼接到名字上
      newCompsMap[`${compName}${key === 'Index' ? '' : key}`] = compsMap[key]
    })
  })
  return newCompsMap
}

const components = {
  ...extractComps({
    Table,
    Chart,
    Graph,
    Progress,
    ReadMore,
    Scroller,
    SearchForm,
  }),
  Descriptions,
  Desc,
  DescItem,
  Searcher,
  RadioGroup,
  CheckboxGroup,
  Selector,
  ...Buttons,
  ...Menu,
}

export default components
